home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / hotlist_source / source / hotlist.module.h < prev    next >
C/C++ Source or Header  |  1996-10-16  |  10KB  |  238 lines

  1. #define CATCOMP_NUMBERS
  2. #include "hotlist.module.strings"
  3.  
  4. #define _DOPUS_MODULE_DEF
  5. #include <dopus/modules.h>
  6.  
  7. #include <ctype.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <stdarg.h>
  12. #include <exec/exec.h>
  13. #include <proto/exec.h>
  14. #include <dos/dos.h>
  15. #include <clib/dos_protos.h>
  16. #include <pragmas/dos_pragmas.h>
  17. #include <libraries/asl.h>
  18. #include <clib/asl_protos.h>
  19. #include <pragmas/asl_pragmas.h>
  20. #include <clib/intuition_protos.h>
  21. #include <pragmas/intuition_pragmas.h>
  22. #include <clib/utility_protos.h>
  23. #include <pragmas/utility_pragmas.h>
  24.  
  25. #include "ResourceNodes.h"
  26.  
  27. /**************************************************************************************/
  28.  
  29. extern struct SignalSemaphore *configsemaphore;        // From special modinit code.
  30.  
  31. /**************************************************************************************/
  32.  
  33. /*= Magic Numbers ====================================================================*/
  34.  
  35. #define MIN_OPUS_VERSION 55                // Minimum version of dopus5.library required.
  36. #define MIN_EXEC_VERSION 37                // Minimum version of exec.library required.
  37. #define PUDDLESIZE 5120                    // Size of memory-pool puddles.
  38. #define THRESHSIZE 4096                    // Allocations above this size get own puddle.
  39.  
  40. #define HEPUDDLESIZE 5120                // -._ As above, but for memory pool used
  41. #define HETHRESHSIZE 4096                // -'  exclusively for hotlist-entries.
  42.  
  43. #define INFORMUSERBUFFERSIZE 1024        // Buffer for writting InformUser() strings to.
  44. #define COMMBUFFSIZE 1024                // Size of buffers for (ARexx) command strings.
  45.  
  46. #define PATHBUFFSIZE 512                // Size of buffers for file paths.
  47. /*
  48. #define NAMEBUFFSIZE 32                    // Size of buffers for file names.
  49. */
  50.  
  51. #define HOTENTPATHLEN PATHBUFFSIZE        // Size of respective buffers for each
  52. #define HOTENTNAMELEN 50                // HotEntry's path and name.
  53.  
  54. #define HOTTYPE_DIR  2                    // Numbers representing different types.
  55. //#define HOTTYPE_FILE 4                    // These are also passed to Opus when
  56. #define HOTTYPE_FILE 1                    // These are also passed to Opus when
  57. #define HOTTYPE_DEV  -2                    // the file is added.
  58. #define HOTTYPE_HOT  -4                    // (For sub-hotlists).
  59.  
  60. #define GCS_SHARED 0                    // Shared type for getConfigSemaphore()
  61. #define GCS_EXCLUSIVE 1                    // Exclusive type for getConfigSemaphore()
  62.  
  63. #define CONFIGVER 1                        // Version of the config-file format.
  64.  
  65. #define DEFAULT_CONFIG "DOpus5:System/Hotlist.prefs"
  66.  
  67. #define CMD_TEMPLATE "NEW/S,CONFIG,LISTER/K"
  68. enum {ARG_NEW,ARG_CONFIG,ARG_LISTER};
  69.  
  70. /*= Flags ============================================================================*/
  71.  
  72. #define IU_CANCEL 1                        // For informUser().
  73.  
  74.  
  75. /*= Non-Localized strings ============================================================*/
  76. #define PORTNAME_FMT "dohotlist.%d"
  77. #define PORTNAME_PREFIX "dohotlist."
  78.  
  79. /*= Macros ===========================================================================*/
  80. #define TEXT_INTERNAL_ERROR DOpusGetString(locale,MSG_INTERNAL_ERROR)
  81. #define dgs(A) DOpusGetString(locale,A)
  82. #define TAGIF(expr,tag) ((expr) ? (tag) : (TAG_IGNORE))
  83. #define TAGNOT(expr,tag) ((expr) ? (TAG_IGNORE) : (tag))
  84.  
  85. /*= Misc. TypeDefs ===================================================================*/
  86. typedef struct hotent
  87. {
  88.     struct hotent *next;
  89.     BOOL deleted;
  90.     char name[HOTENTNAMELEN];
  91.     char path[HOTENTPATHLEN];
  92.     WORD type;
  93. } HotEntry;
  94.  
  95. typedef struct configlistnode
  96. {
  97.     struct configlistnode *parent;    // Previous ConfigListNode.
  98.     ResNode *rn;        // ResNode containing the filename.
  99.     ResNode *rn_self;    // ResNode containing this ConfigListNode.
  100. } ConfigListNode;
  101.  
  102. typedef struct
  103. {
  104.     int x;                            // -.
  105.     int y;                            //  |_ Geometry used when
  106.     int w;                            //  |  openning a new lister.
  107.     int h;                            // -'  (-1 for all means "don't use")
  108. } Snapshot;
  109.  
  110.  
  111. /*= Pseudo-global variables ==========================================================-.
  112. || This is a re-entrant library so real global variables cannot be used.              ||
  113. || Instead we allocate this structure and pass the pointer to it around.              ||
  114. ||------------------------------------------------------------------------------------||
  115. || These must all default to NULL when allocated (MEMF_CLEAR must be given).          ||
  116. `-====================================================================================*/
  117. typedef struct
  118. {
  119.     IPCData *ipc;                        // -._ Copies of commonly used
  120.     EXT_FUNC(func_callback);            // -'  values from Opus.
  121.  
  122.     BOOL new;                            // TRUE if "new" switch given on command-line.
  123.     char *config;                        // Pointer to current config filename.
  124.     char *originalconfig;                // Pointer to original config filename.
  125.     ConfigListNode *conflist;            // 'Parent' config filenames list.
  126.  
  127.     ResNode_Data rnd;                    // For ResourceNode routines.
  128.  
  129.     APTR hentspool;                        // Memory pool for hotlist-entries.
  130.     HotEntry *hentbase;                    // First hotlist-entry in linked list, or NULL.
  131.  
  132.     struct MsgPort *msgport;            // Our message port.
  133.     char mpname[32];                    // Name of our message port.
  134.  
  135.     char lister[24];                    // Handle of our lister (ASCII string).
  136.     APTR listerhandle;                    // Handle of our lister (APTR).
  137.  
  138.     Snapshot snap;                        // Geometry used when openning a new lister.
  139.     char parent[PATHBUFFSIZE];            // Original path of our lister, if any.
  140.  
  141.     struct ClockData time;
  142.  
  143.     ULONG notsigmask;                    // Bitmask containing notification signal.
  144.     BOOL notifyon;                        // If TRUE we have notification ON.
  145.     struct NotifyRequest notify;
  146.  
  147. } Hotlist_Data;
  148.  
  149. /*= IFF ID's =========================================================================*/
  150.  
  151. // MAKE_ID() below taken from iffparse.library's header file. Remove from here if
  152. // it is also included.
  153. #define MAKE_ID(a,b,c,d)    \
  154.     ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  155.  
  156. #define ID_DOHL        MAKE_ID('D','O','H','L')
  157. #define ID_NAME        MAKE_ID('N','A','M','E')
  158. #define ID_PATH        MAKE_ID('P','A','T','H')
  159. #define ID_TYPE        MAKE_ID('T','Y','P','E')
  160. #define ID_SNAP        MAKE_ID('S','N','A','P')
  161. #define ID_VERS        MAKE_ID('V','E','R','S')
  162. #define ID_TIME        MAKE_ID('T','I','M','E')
  163.  
  164. /*= Prototypes =======================================================================*/
  165.  
  166. long informUser(Hotlist_Data *data,char *format,BOOL window,ULONG flags,...);
  167. long getString(Hotlist_Data *data,char *format,BOOL window,ULONG flags,\
  168.                 char *strbuff,long bufflen,...);
  169. long getPathString(Hotlist_Data *data,char *format,BOOL window,ULONG flags,\
  170.                 char *strbuff,long bufflen,...);
  171.  
  172. BOOL getListerHandle(Hotlist_Data *data);
  173. void sendExtCmd_nr(Hotlist_Data *data,char *cmdstring,struct command_packet *cpp);
  174. void addEntries(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  175. void mainEventLoop(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  176. void writeConfigFile(Hotlist_Data *data);
  177. void readConfigFile(Hotlist_Data *data,BOOL alreadylocked);
  178. void splent(Hotlist_Data *data,BOOL alreadylocked,struct ClockData *newtime,char *msg);
  179. void rereadConfig(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  180. HotEntry *newHotEntry(Hotlist_Data *data);
  181. void remHotEntry(Hotlist_Data *data);
  182. void setHotType(Hotlist_Data *data,HotEntry *nhe);
  183. void wordcpy(char *dest,char **source);
  184. int wordcount(char *wordstring);
  185. HotEntry *findHotEntry(Hotlist_Data *data,char *searchname);
  186. BOOL findOldEntry(Hotlist_Data *data,char *searchname);
  187. struct Window *getListerWindow(Hotlist_Data *data);
  188. struct Screen *getDOpusScreen(Hotlist_Data *data);
  189. void listerRead(Hotlist_Data *data,char *combuf,struct command_packet *cpp,char *path);
  190.  
  191. FuncArgs *parseArgs(Hotlist_Data *data,char *args);
  192. void freeArgs(FuncArgs *fa);
  193.  
  194. void endcpy(char *dest,char *source,long destlen);
  195. char *leofilepart(char *path);
  196.  
  197. LONG notHandled(Hotlist_Data *data,char *combuf,struct command_packet *cpp,char *lh);
  198.  
  199. BOOL addMsgPort(Hotlist_Data *data);
  200. void remMsgPort(Hotlist_Data *data);
  201.  
  202. void basicListerInit(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  203.  
  204. BOOL event_inactive(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  205.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  206. BOOL event_doubleclick(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  207.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  208. BOOL event_dropfrom(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  209.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  210. BOOL event_drop(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  211.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  212. BOOL event_makedir(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  213.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  214. BOOL event_delete(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  215.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  216. BOOL event_path(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  217.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  218. BOOL event_scandir_hotlist(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  219.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  220. BOOL event_snapshot(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  221.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  222. BOOL event_unsnapshot(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  223.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  224. BOOL event_rename(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  225.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  226. BOOL event_parent(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  227.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  228. BOOL event_duplicate(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  229.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  230.  
  231. void getConfigSemaphore(Hotlist_Data *data,short obtype);
  232. void getWriteConfigSemaphore(Hotlist_Data *data);
  233.  
  234. void notifyOn(Hotlist_Data *data);
  235. void notifyOff(Hotlist_Data *data);
  236.  
  237. char *skipSpaces(char *text,int numspac);
  238.